package ch.rheintalconnection.sysventory.presentation;

import java.util.List;

import ch.rheintalconnection.sysventory.domain.Program;

import com.vaadin.data.Item;
import com.vaadin.ui.Table;
import com.vaadin.ui.Window;

public class ProgramWindow extends Window{
	
	private static final long serialVersionUID = -170568458710245416L;

	public ProgramWindow(List<Program> programs){
		this.setCaption("Programme");
		this.setWidth("800px");
		this.setHeight("800px");
		
		Table table = new Table();
		table.setSizeFull();
		this.addComponent(table);
		
		
		table.addContainerProperty("Programmname", String.class, null);
		table.addContainerProperty("Version", String.class, null);
		
		for (Program program : programs) {
			Object newItemId = table.addItem();
			Item row = table.getItem(newItemId);
			
			row.getItemProperty("Programmname").setValue(program.getDescription());
			row.getItemProperty("Version").setValue(program.getVersion());
		}
	}
}
